package com.example.hdwx.myapplication.untils;

import android.content.Context;
import android.widget.ImageView;

import com.example.hdwx.myapplication.R;
import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiscCache;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
import com.nostra13.universalimageloader.core.display.RoundedBitmapDisplayer;
import com.nostra13.universalimageloader.utils.StorageUtils;

import java.io.Console;
import java.io.File;

/**
 * Created by hdwx on 2017/2/13.
 */

public class ImageShow {
    public void image_show(Context context, String path, ImageView imageView){
        ImageLoader imageLoader=ImageLoader.getInstance();
        File file= StorageUtils.getOwnCacheDirectory(context,"daydaycook/image");
        ImageLoaderConfiguration configuration=new ImageLoaderConfiguration.Builder(context)
                .threadPoolSize(3)
                .discCache(new UnlimitedDiscCache(file))
                .discCacheSize(200)
                .memoryCacheExtraOptions(480,800)
                .build();
        imageLoader.init(configuration);
        DisplayImageOptions options=new DisplayImageOptions.Builder()
                .showImageOnLoading(R.mipmap.ic_launcher)
                .showImageForEmptyUri(R.mipmap.ic_launcher)
                .cacheInMemory(true)

                //启用外存缓存
                .cacheOnDisc(true)
                .imageScaleType(ImageScaleType.IN_SAMPLE_INT)
                //设置角度
               //.displayer(new RoundedBitmapDisplayer(i))
                .build();
        imageLoader.displayImage(path,imageView,options);
    }
}
